using Crux.Core.Dapper;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;

namespace System;
/// <summary>
/// 
/// </summary>
public static class DapperServiceCollectionExtensions
{
    /// <summary>
    ///
    /// </summary>
    /// <param name="services"></param>
    /// <returns></returns>
    public static IServiceCollection AddDapper(
       this IServiceCollection services)
    {
        services.TryAddScoped(typeof(IDbContextFactory<>), typeof(DbContextFactory<>));
        services.TryAddScoped(typeof(IExecuteListener), typeof(ExecuteListener));
        services.TryAddScoped(typeof(IQueryRepository<>), typeof(QueryRepository<>));
        services.TryAddScoped(typeof(IUnitOfWork<>), typeof(UnitOfWork<>));

        return services;
    }
}